
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>7.1 常规性能调优 · 大数据 bigdata_spark_kernel-optimize_atguigu 课堂笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content=" 李振超">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-page-toc-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-change_girls/girls.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="72-suan-zi-diao-you.html" />
    
    
    <link rel="prev" href="../di-7-zhang-spark-xing-neng-you-hua.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.atguigu.com/" target="_blank" class="custom-link">联系我们</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        <li class="header">第 1 部分: Spark 内核</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    第 1 章 Spark 内核概述
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../../11-spark-he-xin-zu-jian-hui-gu.html">
            
                <a href="../../11-spark-he-xin-zu-jian-hui-gu.html">
            
                    
                    1.1 Spark 核心组件回顾
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="../../12-spark-tong-yong-yun-xing-liu-cheng-gai-shu.html">
            
                <a href="../../12-spark-tong-yong-yun-xing-liu-cheng-gai-shu.html">
            
                    
                    1.2 Spark 通用运行流程概述
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../chapter1.html">
            
                <a href="../../chapter1.html">
            
                    
                    第 2 章 Spark 通讯架构
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../chapter1/21-spark-tong-xun-jia-gou-gai-shu.html">
            
                <a href="../../chapter1/21-spark-tong-xun-jia-gou-gai-shu.html">
            
                    
                    2.1 Spark 通讯架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../chapter1/23-spark-tong-xin-jia-gou-jie-xi.html">
            
                <a href="../../chapter1/23-spark-tong-xin-jia-gou-jie-xi.html">
            
                    
                    2.2 Spark 通信架构解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../chapter1/22-spark-qi-dong-liu-cheng-fen-xi.html">
            
                <a href="../../chapter1/22-spark-qi-dong-liu-cheng-fen-xi.html">
            
                    
                    2.3 Spark 启动流程分析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.3.1" data-path="../../chapter1/22-spark-qi-dong-liu-cheng-fen-xi/231-master-liu-cheng-fen-xi.html">
            
                <a href="../../chapter1/22-spark-qi-dong-liu-cheng-fen-xi/231-master-liu-cheng-fen-xi.html">
            
                    
                    2.3.1 Master 启动源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.2" data-path="../../chapter1/22-spark-qi-dong-liu-cheng-fen-xi/232-worker-liu-cheng-fen-xi.html">
            
                <a href="../../chapter1/22-spark-qi-dong-liu-cheng-fen-xi/232-worker-liu-cheng-fen-xi.html">
            
                    
                    2.3.2 Worker 启动源码分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../di-3-zhang-spark-bu-shu-mo-shi.html">
            
                <a href="../../di-3-zhang-spark-bu-shu-mo-shi.html">
            
                    
                    第 3 章 Spark 部署模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../di-3-zhang-spark-bu-shu-mo-shi/31-yarn-mo-shi-yun-xing-ji-zhi.html">
            
                <a href="../../di-3-zhang-spark-bu-shu-mo-shi/31-yarn-mo-shi-yun-xing-ji-zhi.html">
            
                    
                    3.1 Yarn 模式运行机制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="../../di-3-zhang-spark-bu-shu-mo-shi/31-yarn-mo-shi-yun-xing-ji-zhi/yarn-mo-shi-yun-xing-ji-zhi-yuan-ma-fen-xi.html">
            
                <a href="../../di-3-zhang-spark-bu-shu-mo-shi/31-yarn-mo-shi-yun-xing-ji-zhi/yarn-mo-shi-yun-xing-ji-zhi-yuan-ma-fen-xi.html">
            
                    
                    1. Yarn cluster 模式运行机制源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="../../di-3-zhang-spark-bu-shu-mo-shi/31-yarn-mo-shi-yun-xing-ji-zhi/yarn-client-mo-shi-yun-xing-ji-zhi-yuan-ma-fen-xi.html">
            
                <a href="../../di-3-zhang-spark-bu-shu-mo-shi/31-yarn-mo-shi-yun-xing-ji-zhi/yarn-client-mo-shi-yun-xing-ji-zhi-yuan-ma-fen-xi.html">
            
                    
                    2. Yarn client 模式运行机制源码分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../di-3-zhang-spark-bu-shu-mo-shi/32-standalone-mo-shi-yun-xing-ji-zhi.html">
            
                <a href="../../di-3-zhang-spark-bu-shu-mo-shi/32-standalone-mo-shi-yun-xing-ji-zhi.html">
            
                    
                    3.2 Standalone 模式运行机制
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi.html">
            
                    
                    第 4 章 Spark 任务调度机制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/41-spark-ren-wu-diao-du-gai-shu.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/41-spark-ren-wu-diao-du-gai-shu.html">
            
                    
                    4.1 Spark 任务调度概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/42-spark-stage-ji-bie-diao-du.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/42-spark-stage-ji-bie-diao-du.html">
            
                    
                    4.2 Spark Stage 级别调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du.html">
            
                    
                    4.3 Spark Task 级别调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.3.1" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du/431-diao-du-ce-lve.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du/431-diao-du-ce-lve.html">
            
                    
                    4.3.1 调度策略
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3.2" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du/432-ben-di-hua-diao-du.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du/432-ben-di-hua-diao-du.html">
            
                    
                    4.3.2 本地化调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3.3" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du/433-shi-bai-zhong-shi-he-hei-ming-dan.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/43-spark-task-ji-bie-diao-du/433-shi-bai-zhong-shi-he-hei-ming-dan.html">
            
                    
                    4.3.3 失败重试和黑名单
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/44-ren-wu-diao-du-yuan-ma-fen-xi.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/44-ren-wu-diao-du-yuan-ma-fen-xi.html">
            
                    
                    4.4 Stage 级别任务调度源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/45-task-ji-bie-ren-wu-diao-du-yuan-ma-fen-xi.html">
            
                <a href="../../di-4-zhang-spark-ren-wu-diao-du-ji-zhi/45-task-ji-bie-ren-wu-diao-du-yuan-ma-fen-xi.html">
            
                    
                    4.5 Task 级别任务调度源码分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../di-5-zhang-spark-shuffle-jie-xi.html">
            
                <a href="../../di-5-zhang-spark-shuffle-jie-xi.html">
            
                    
                    第 5 章 Spark Shuffle 解析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../di-5-zhang-spark-shuffle-jie-xi/51-shuffle-de-he-xin-yao-dian.html">
            
                <a href="../../di-5-zhang-spark-shuffle-jie-xi/51-shuffle-de-he-xin-yao-dian.html">
            
                    
                    5.1 Shuffle 的核心要点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../../di-5-zhang-spark-shuffle-jie-xi/52-hashshuffle-jie-xi.html">
            
                <a href="../../di-5-zhang-spark-shuffle-jie-xi/52-hashshuffle-jie-xi.html">
            
                    
                    5.2 HashShuffle 解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../../di-5-zhang-spark-shuffle-jie-xi/53-sortshuffle-jie-xi.html">
            
                <a href="../../di-5-zhang-spark-shuffle-jie-xi/53-sortshuffle-jie-xi.html">
            
                    
                    5.3 SortShuffle 解析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.3.1" data-path="../../di-5-zhang-spark-shuffle-jie-xi/53-sortshuffle-jie-xi/sortshuffle-yuan-ma-jie-xi.html">
            
                <a href="../../di-5-zhang-spark-shuffle-jie-xi/53-sortshuffle-jie-xi/sortshuffle-yuan-ma-jie-xi.html">
            
                    
                    SortShuffle 源码解析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../di-6-zhang-spark-nei-cun-jie-xi.html">
            
                <a href="../../di-6-zhang-spark-nei-cun-jie-xi.html">
            
                    
                    第 6 章 Spark 内存管理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../../61-dui-nei-he-dui-wai-nei-cun-gui-hua.html">
            
                <a href="../../61-dui-nei-he-dui-wai-nei-cun-gui-hua.html">
            
                    
                    6.1 堆内核堆外内存规划
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../../62-nei-cun-kong-jian-fen-pei.html">
            
                <a href="../../62-nei-cun-kong-jian-fen-pei.html">
            
                    
                    6.2 内存空间分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../../63-cun-chu-nei-cun-guan-li.html">
            
                <a href="../../63-cun-chu-nei-cun-guan-li.html">
            
                    
                    6.3 存储内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../../64-zhi-xing-nei-cun-guan-li.html">
            
                <a href="../../64-zhi-xing-nei-cun-guan-li.html">
            
                    
                    6.4 执行内存管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 2 部分: Spark 性能优化和故障处理</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../di-7-zhang-spark-xing-neng-you-hua.html">
            
                <a href="../di-7-zhang-spark-xing-neng-you-hua.html">
            
                    
                    第 7 章 Spark 性能优化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="2.1.1" data-path="71-chang-gui-xing-neng-diao-you.html">
            
                <a href="71-chang-gui-xing-neng-diao-you.html">
            
                    
                    7.1 常规性能调优
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="72-suan-zi-diao-you.html">
            
                <a href="72-suan-zi-diao-you.html">
            
                    
                    7.2 算子调优
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="73-shuffle-diao-you.html">
            
                <a href="73-shuffle-diao-you.html">
            
                    
                    7.3 Shuffle 调优
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="74-jvm-diao-you.html">
            
                <a href="74-jvm-diao-you.html">
            
                    
                    7.4 JVM 调优
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../di-8-zhang-spark-shu-ju-qing-xie.html">
            
                <a href="../di-8-zhang-spark-shu-ju-qing-xie.html">
            
                    
                    第 8 章 Spark 数据倾斜解决方案
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../di-9-zhang-spark-troubleshooting.html">
            
                <a href="../di-9-zhang-spark-troubleshooting.html">
            
                    
                    第 9 章 Spark Troubleshooting
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >7.1 常规性能调优</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="71-&#x5E38;&#x89C4;&#x6027;&#x80FD;&#x8C03;&#x4F18;">7.1 &#x5E38;&#x89C4;&#x6027;&#x80FD;&#x8C03;&#x4F18;</h1>
<h2 id="711-&#x6700;&#x4F18;&#x8D44;&#x6E90;&#x914D;&#x7F6E;">7.1.1 &#x6700;&#x4F18;&#x8D44;&#x6E90;&#x914D;&#x7F6E;</h2>
<p>Spark &#x6027;&#x80FD;&#x8C03;&#x4F18;&#x7684;&#x7B2C;&#x4E00;&#x6B65;&#xFF0C;&#x5C31;&#x662F;&#x4E3A;&#x4EFB;&#x52A1;&#x5206;&#x914D;&#x66F4;&#x591A;&#x7684;&#x8D44;&#x6E90;&#xFF0C;<my>&#x5728;&#x4E00;&#x5B9A;&#x8303;&#x56F4;&#x5185;&#xFF0C;&#x589E;&#x52A0;&#x8D44;&#x6E90;&#x7684;&#x5206;&#x914D;&#x4E0E;&#x6027;&#x80FD;&#x7684;&#x63D0;&#x5347;&#x662F;&#x6210;&#x6B63;&#x6BD4;&#x7684;</my>&#xFF0C;&#x5B9E;&#x73B0;&#x4E86;&#x6700;&#x4F18;&#x7684;&#x8D44;&#x6E90;&#x914D;&#x7F6E;&#x540E;&#xFF0C;&#x5728;&#x6B64;&#x57FA;&#x7840;&#x4E0A;&#x518D;&#x8003;&#x8651;&#x8FDB;&#x884C;&#x540E;&#x9762;&#x8BBA;&#x8FF0;&#x7684;&#x6027;&#x80FD;&#x8C03;&#x4F18;&#x7B56;&#x7565;&#x3002;</p>
<p>&#x8D44;&#x6E90;&#x7684;&#x5206;&#x914D;&#x5728;&#x4F7F;&#x7528;&#x811A;&#x672C;&#x63D0;&#x4EA4;Spark&#x4EFB;&#x52A1;&#x65F6;&#x8FDB;&#x884C;&#x6307;&#x5B9A;&#xFF0C;&#x6807;&#x51C6;&#x7684;Spark&#x4EFB;&#x52A1;&#x63D0;&#x4EA4;&#x811A;&#x672C;&#x5982;&#x4EE3;&#x7801;&#x6E05;&#x5355;:</p>
<pre class="language-"><code class="lang-bash">/usr/opt/modules/spark/bin/spark-submit \
--class com.atguigu.spark.Analysis \
--num-executors 80 \
--driver-memory 6g \
--executor-memory 6g \
--executor-cores 3 \
/usr/opt/modules/spark/jar/spark.jar \
</code></pre>
<table>
<thead>
<tr>
<th><strong>&#x540D;&#x79F0;</strong></th>
<th><strong>&#x8BF4;&#x660E;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>--num-executors</strong></td>
<td>&#x914D;&#x7F6E;Executor&#x7684;&#x6570;&#x91CF;</td>
</tr>
<tr>
<td><strong>--driver-memory</strong></td>
<td>&#x914D;&#x7F6E;Driver&#x5185;&#x5B58;&#xFF08;&#x5F71;&#x54CD;&#x4E0D;&#x5927;&#xFF09;</td>
</tr>
<tr>
<td><strong>--executor-memory</strong></td>
<td>&#x914D;&#x7F6E;&#x6BCF;&#x4E2A;Executor&#x7684;&#x5185;&#x5B58;&#x5927;&#x5C0F;</td>
</tr>
<tr>
<td><strong>--executor-cores</strong></td>
<td>&#x914D;&#x7F6E;&#x6BCF;&#x4E2A;Executor&#x7684;CPU core&#x6570;&#x91CF;</td>
</tr>
</tbody>
</table>
<p>&#x8C03;&#x8282;&#x539F;&#x5219;&#xFF1A;&#x5C3D;&#x91CF;&#x5C06;&#x4EFB;&#x52A1;&#x5206;&#x914D;&#x7684;&#x8D44;&#x6E90;&#x8C03;&#x8282;&#x5230;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x7684;&#x6700;&#x5927;&#x9650;&#x5EA6;&#x3002;</p>
<blockquote>
<p>&#x5BF9;&#x4E8E;&#x5177;&#x4F53;&#x8D44;&#x6E90;&#x7684;&#x5206;&#x914D;&#xFF0C;&#x6211;&#x4EEC;&#x5206;&#x522B;&#x8BA8;&#x8BBA; Spark &#x7684;&#x4E24;&#x79CD; Cluste &#x8FD0;&#x884C;&#x6A21;&#x5F0F;&#xFF1A;</p>
</blockquote>
<ul>
<li><p>&#x7B2C;&#x4E00;&#x79CD;&#x662F;Spark Standalone&#x6A21;&#x5F0F;&#xFF0C;&#x4F60;&#x5728;&#x63D0;&#x4EA4;&#x4EFB;&#x52A1;&#x524D;&#xFF0C;&#x4E00;&#x5B9A;&#x77E5;&#x9053;&#x6216;&#x8005;&#x53EF;&#x4EE5;&#x4ECE;&#x8FD0;&#x7EF4;&#x90E8;&#x95E8;&#x83B7;&#x53D6;&#x5230;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x60C5;&#x51B5;&#xFF0C;&#x5728;&#x7F16;&#x5199;submit&#x811A;&#x672C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x6839;&#x636E;&#x53EF;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x60C5;&#x51B5;&#x8FDB;&#x884C;&#x8D44;&#x6E90;&#x7684;&#x5206;&#x914D;&#xFF0C;&#x6BD4;&#x5982;&#x8BF4;&#x96C6;&#x7FA4;&#x6709;15&#x53F0;&#x673A;&#x5668;&#xFF0C;&#x6BCF;&#x53F0;&#x673A;&#x5668;&#x4E3A;8G&#x5185;&#x5B58;&#xFF0C;2&#x4E2A;CPU core&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x6307;&#x5B9A;15&#x4E2A;Executor&#xFF0C;&#x6BCF;&#x4E2A;Executor&#x5206;&#x914D;8G&#x5185;&#x5B58;&#xFF0C;2&#x4E2A;CPU core&#x3002;</p>
</li>
<li><p>&#x7B2C;&#x4E8C;&#x79CD;&#x662F;Spark Yarn&#x6A21;&#x5F0F;&#xFF0C;&#x7531;&#x4E8E;Yarn&#x4F7F;&#x7528;&#x8D44;&#x6E90;&#x961F;&#x5217;&#x8FDB;&#x884C;&#x8D44;&#x6E90;&#x7684;&#x5206;&#x914D;&#x548C;&#x8C03;&#x5EA6;&#xFF0C;&#x5728;&#x8868;&#x5199; submit &#x811A;&#x672C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x6839;&#x636E;Spark&#x4F5C;&#x4E1A;&#x8981;&#x63D0;&#x4EA4;&#x5230;&#x7684;&#x8D44;&#x6E90;&#x961F;&#x5217;&#xFF0C;&#x8FDB;&#x884C;&#x8D44;&#x6E90;&#x7684;&#x5206;&#x914D;&#xFF0C;&#x6BD4;&#x5982;&#x8D44;&#x6E90;&#x961F;&#x5217;&#x6709;400G&#x5185;&#x5B58;&#xFF0C;100&#x4E2A;CPU core&#xFF0C;&#x90A3;&#x4E48;&#x6307;&#x5B9A;50&#x4E2A;Executor&#xFF0C;&#x6BCF;&#x4E2A;Executor&#x5206;&#x914D;8G&#x5185;&#x5B58;&#xFF0C;2&#x4E2A;CPU core&#x3002;</p>
</li>
</ul>
<blockquote>
<p>&#x8D44;&#x6E90;&#x8C03;&#x8282;&#x540E;&#x7684;&#x6027;&#x80FD;&#x63D0;&#x5347;</p>
</blockquote>
<table>
<thead>
<tr>
<th><strong>&#x540D;&#x79F0;</strong></th>
<th><strong>&#x89E3;&#x6790;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>&#x589E;&#x52A0;Executor&#xB7;&#x4E2A;&#x6570;</strong></td>
<td>&#x5728;&#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x589E;&#x52A0;Executor&#x7684;&#x4E2A;&#x6570;&#x53EF;&#x4EE5;&#x63D0;&#x9AD8;&#x6267;&#x884C;task&#x7684;&#x5E76;&#x884C;&#x5EA6;&#x3002;&#x6BD4;&#x5982;&#x6709;4&#x4E2A;Executor&#xFF0C;&#x6BCF;&#x4E2A;Executor&#x6709;2&#x4E2A;CPU   core&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x6267;&#x884C;8&#x4E2A;task&#xFF0C;&#x5982;&#x679C;&#x5C06;Executor&#x7684;&#x4E2A;&#x6570;&#x589E;&#x52A0;&#x5230;8&#x4E2A;&#xFF08;&#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF09;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x6267;&#x884C;16&#x4E2A;task&#xFF0C;&#x6B64;&#x65F6;&#x7684;&#x5E76;&#x884C;&#x80FD;&#x529B;&#x63D0;&#x5347;&#x4E86;&#x4E00;&#x500D;&#x3002;</td>
</tr>
<tr>
<td><strong>&#x589E;&#x52A0;&#x6BCF;&#x4E2A;Executor&#x7684;CPU core&#x4E2A;&#x6570;</strong></td>
<td>&#x5728;&#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x589E;&#x52A0;&#x6BCF;&#x4E2A;Executor&#x7684;Cpu core&#x4E2A;&#x6570;&#xFF0C;&#x53EF;&#x4EE5;&#x63D0;&#x9AD8;&#x6267;&#x884C;task&#x7684;&#x5E76;&#x884C;&#x5EA6;&#x3002;&#x6BD4;&#x5982;&#x6709;4&#x4E2A;Executor&#xFF0C;&#x6BCF;&#x4E2A;Executor&#x6709;2&#x4E2A;CPU   core&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x6267;&#x884C;8&#x4E2A;task&#xFF0C;&#x5982;&#x679C;&#x5C06;&#x6BCF;&#x4E2A;Executor&#x7684;CPU   core&#x4E2A;&#x6570;&#x589E;&#x52A0;&#x5230;4&#x4E2A;&#xFF08;&#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF09;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x6267;&#x884C;16&#x4E2A;task&#xFF0C;&#x6B64;&#x65F6;&#x7684;&#x5E76;&#x884C;&#x80FD;&#x529B;&#x63D0;&#x5347;&#x4E86;&#x4E00;&#x500D;&#x3002;</td>
</tr>
<tr>
<td><strong>&#x589E;&#x52A0;&#x6BCF;&#x4E2A;Executor&#x7684;&#x5185;&#x5B58;&#x91CF;</strong></td>
<td>&#x5728;&#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x589E;&#x52A0;&#x6BCF;&#x4E2A;Executor&#x7684;&#x5185;&#x5B58;&#x91CF;&#x4EE5;&#x540E;&#xFF0C;&#x5BF9;&#x6027;&#x80FD;&#x7684;&#x63D0;&#x5347;&#x6709;&#x4E09;&#x70B9;&#xFF1A;   1.   <my>&#x53EF;&#x4EE5;&#x7F13;&#x5B58;&#x66F4;&#x591A;&#x7684;&#x6570;&#x636E;&#xFF08;&#x5373;&#x5BF9;RDD&#x8FDB;&#x884C;cache&#xFF09;</my>&#xFF0C;&#x5199;&#x5165;&#x78C1;&#x76D8;&#x7684;&#x6570;&#x636E;&#x76F8;&#x5E94;&#x51CF;&#x5C11;&#xFF0C;&#x751A;&#x81F3;&#x53EF;&#x4EE5;&#x4E0D;&#x5199;&#x5165;&#x78C1;&#x76D8;&#xFF0C;&#x51CF;&#x5C11;&#x4E86;&#x53EF;&#x80FD;&#x7684;&#x78C1;&#x76D8;IO&#xFF1B;   2.   <my>&#x53EF;&#x4EE5;&#x4E3A;shuffle&#x64CD;&#x4F5C;&#x63D0;&#x4F9B;&#x66F4;&#x591A;&#x5185;&#x5B58;</my>&#xFF0C;&#x5373;&#x6709;&#x66F4;&#x591A;&#x7A7A;&#x95F4;&#x6765;&#x5B58;&#x653E;reduce&#x7AEF;&#x62C9;&#x53D6;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5199;&#x5165;&#x78C1;&#x76D8;&#x7684;&#x6570;&#x636E;&#x76F8;&#x5E94;&#x51CF;&#x5C11;&#xFF0C;&#x751A;&#x81F3;&#x53EF;&#x4EE5;&#x4E0D;&#x5199;&#x5165;&#x78C1;&#x76D8;&#xFF0C;&#x51CF;&#x5C11;&#x4E86;&#x53EF;&#x80FD;&#x7684;&#x78C1;&#x76D8;IO&#xFF1B;   3.   <my>&#x53EF;&#x4EE5;&#x4E3A;task&#x7684;&#x6267;&#x884C;&#x63D0;&#x4F9B;&#x66F4;&#x591A;&#x5185;&#x5B58;</my>&#xFF0C;&#x5728;task&#x7684;&#x6267;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#x53EF;&#x80FD;&#x521B;&#x5EFA;&#x5F88;&#x591A;&#x5BF9;&#x8C61;&#xFF0C;&#x5185;&#x5B58;&#x8F83;&#x5C0F;&#x65F6;&#x4F1A;&#x5F15;&#x53D1;&#x9891;&#x7E41;&#x7684;GC&#xFF0C;&#x589E;&#x52A0;&#x5185;&#x5B58;&#x540E;&#xFF0C;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x9891;&#x7E41;&#x7684;GC&#xFF0C;&#x63D0;&#x5347;&#x6574;&#x4F53;&#x6027;&#x80FD;&#x3002;</td>
</tr>
</tbody>
</table>
<h3 id="&#x751F;&#x4EA7;&#x73AF;&#x5883;spark-submit&#x811A;&#x672C;&#x914D;&#x7F6E;">&#x751F;&#x4EA7;&#x73AF;&#x5883;Spark submit&#x811A;&#x672C;&#x914D;&#x7F6E;</h3>
<pre class="language-"><code class="lang-scala"><span class="token operator">/</span>usr<span class="token operator">/</span>local<span class="token operator">/</span>spark<span class="token operator">/</span>bin<span class="token operator">/</span>spark<span class="token operator">-</span>submit \
<span class="token operator">--</span><span class="token keyword">class</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>spark<span class="token punctuation">.</span>WordCount \
<span class="token operator">--</span>num<span class="token operator">-</span>executors <span class="token number">80</span> \
<span class="token operator">--</span>driver<span class="token operator">-</span>memory <span class="token number">6</span>g \
<span class="token operator">--</span>executor<span class="token operator">-</span>memory <span class="token number">6</span>g \
<span class="token operator">--</span>executor<span class="token operator">-</span>cores <span class="token number">3</span> \
<span class="token operator">--</span>master yarn \
<span class="token operator">--</span>deploy<span class="token operator">-</span>mode cluster \
<span class="token operator">--</span>queue root<span class="token punctuation">.</span>default \
<span class="token operator">--</span>conf spark<span class="token punctuation">.</span>yarn<span class="token punctuation">.</span>executor<span class="token punctuation">.</span>memoryOverhead<span class="token operator">=</span><span class="token number">2048</span> \
<span class="token operator">--</span>conf spark<span class="token punctuation">.</span>core<span class="token punctuation">.</span>connection<span class="token punctuation">.</span>ack<span class="token punctuation">.</span>wait<span class="token punctuation">.</span>timeout<span class="token operator">=</span><span class="token number">300</span> \
<span class="token operator">/</span>usr<span class="token operator">/</span>local<span class="token operator">/</span>spark<span class="token operator">/</span>spark<span class="token punctuation">.</span>jar
</code></pre>
<ul>
<li><code>--num-executors&#xFF1A;50~100</code></li>
<li><code>--driver-memory&#xFF1A;1G~5G</code></li>
<li><code>--executor-memory&#xFF1A;6G~10G</code></li>
<li><code>--executor-cores&#xFF1A;3</code></li>
<li><code>--master: yarn</code></li>
<li><code>--deploy-mode:  cluster</code></li>
</ul>
<hr>
<h2 id="712-rdd-&#x4F18;&#x5316;">7.1.2 RDD &#x4F18;&#x5316;</h2>
<h3 id="1-rdd-&#x590D;&#x7528;">1. RDD &#x590D;&#x7528;</h3>
<p>&#x5728;&#x5BF9;RDD&#x8FDB;&#x884C;&#x7B97;&#x5B50;&#x65F6;&#xFF0C;&#x8981;&#x907F;&#x514D;&#x76F8;&#x540C;&#x7684;&#x7B97;&#x5B50;&#x548C;&#x8BA1;&#x7B97;&#x903B;&#x8F91;&#x4E4B;&#x4E0B;&#x5BF9; RDD &#x8FDB;&#x884C;&#x91CD;&#x590D;&#x7684;&#x8BA1;&#x7B97;:</p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1554795569.png-atguiguText" alt=""></p>
<p>&#x5BF9;&#x4E0A;&#x56FE;&#x4E2D;&#x7684;RDD&#x8BA1;&#x7B97;&#x67B6;&#x6784;&#x8FDB;&#x884C;&#x4FEE;&#x6539;:</p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1554795601.png-atguiguText" alt=""></p>
<h3 id="2-rdd-&#x6301;&#x4E45;&#x5316;">2. RDD &#x6301;&#x4E45;&#x5316;</h3>
<p>&#x5728;Spark&#x4E2D;&#xFF0C;&#x5F53;&#x591A;&#x6B21;&#x5BF9;&#x540C;&#x4E00;&#x4E2A; RDD &#x6267;&#x884C;&#x7B97;&#x5B50;&#x64CD;&#x4F5C;&#x65F6;&#xFF0C;&#x6BCF;&#x4E00;&#x6B21;&#x90FD;&#x4F1A;&#x5BF9;&#x8FD9;&#x4E2A; RDD &#x7684;&#x7956;&#x5148; RDD &#x91CD;&#x65B0;&#x8BA1;&#x7B97;&#x4E00;&#x6B21;&#xFF0C;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x662F;&#x5FC5;&#x987B;&#x8981;&#x907F;&#x514D;&#x7684;&#xFF0C;&#x5BF9;&#x540C;&#x4E00;&#x4E2A;RDD&#x7684;&#x91CD;&#x590D;&#x8BA1;&#x7B97;&#x662F;&#x5BF9;&#x8D44;&#x6E90;&#x7684;&#x6781;&#x5927;&#x6D6A;&#x8D39;&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x5FC5;&#x987B;&#x5BF9;&#x591A;&#x6B21;&#x4F7F;&#x7528;&#x7684;RDD&#x8FDB;&#x884C;&#x6301;&#x4E45;&#x5316;&#xFF0C;&#x901A;&#x8FC7;&#x6301;&#x4E45;&#x5316;&#x5C06;&#x516C;&#x5171;RDD&#x7684;&#x6570;&#x636E;&#x7F13;&#x5B58;&#x5230;&#x5185;&#x5B58;/&#x78C1;&#x76D8;&#x4E2D;&#xFF0C;&#x4E4B;&#x540E;&#x5BF9;&#x4E8E;&#x516C;&#x5171;RDD&#x7684;&#x8BA1;&#x7B97;&#x90FD;&#x4F1A;&#x4ECE;&#x5185;&#x5B58;/&#x78C1;&#x76D8;&#x4E2D;&#x76F4;&#x63A5;&#x83B7;&#x53D6;RDD&#x6570;&#x636E;&#x3002;
&#x5BF9;&#x4E8E;RDD&#x7684;&#x6301;&#x4E45;&#x5316;&#xFF0C;&#x6709;&#x4E24;&#x70B9;&#x9700;&#x8981;&#x8BF4;&#x660E;&#xFF1A;</p>
<ol>
<li><p>&#xFF0C;RDD&#x7684;&#x6301;&#x4E45;&#x5316;&#x662F;&#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x5E8F;&#x5217;&#x5316;&#x7684;&#xFF0C;&#x5F53;&#x5185;&#x5B58;&#x65E0;&#x6CD5;&#x5C06;RDD&#x7684;&#x6570;&#x636E;&#x5B8C;&#x6574;&#x7684;&#x8FDB;&#x884C;&#x5B58;&#x653E;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x8003;&#x8651;&#x4F7F;&#x7528;&#x5E8F;&#x5217;&#x5316;&#x7684;&#x65B9;&#x5F0F;&#x51CF;&#x5C0F;&#x6570;&#x636E;&#x4F53;&#x79EF;&#xFF0C;&#x5C06;&#x6570;&#x636E;&#x5B8C;&#x6574;&#x5B58;&#x50A8;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x3002;</p>
</li>
<li><p>&#x5982;&#x679C;&#x5BF9;&#x4E8E;&#x6570;&#x636E;&#x7684;&#x53EF;&#x9760;&#x6027;&#x8981;&#x6C42;&#x5F88;&#x9AD8;&#xFF0C;&#x5E76;&#x4E14;&#x5185;&#x5B58;&#x5145;&#x8DB3;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x526F;&#x672C;&#x673A;&#x5236;&#xFF0C;&#x5BF9;RDD&#x6570;&#x636E;&#x8FDB;&#x884C;&#x6301;&#x4E45;&#x5316;&#x3002;&#x5F53;&#x6301;&#x4E45;&#x5316;&#x542F;&#x7528;&#x4E86;&#x590D;&#x672C;&#x673A;&#x5236;&#x65F6;&#xFF0C;&#x5BF9;&#x4E8E;&#x6301;&#x4E45;&#x5316;&#x7684;&#x6BCF;&#x4E2A;&#x6570;&#x636E;&#x5355;&#x5143;&#x90FD;&#x5B58;&#x50A8;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#xFF0C;&#x653E;&#x5728;&#x5176;&#x4ED6;&#x8282;&#x70B9;&#x4E0A;&#x9762;&#xFF0C;&#x7531;&#x6B64;&#x5B9E;&#x73B0;&#x6570;&#x636E;&#x7684;&#x5BB9;&#x9519;&#xFF0C;&#x4E00;&#x65E6;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#x6570;&#x636E;&#x4E22;&#x5931;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x91CD;&#x65B0;&#x8BA1;&#x7B97;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#x3002;</p>
</li>
</ol>
<h3 id="3-rdd-&#x5C3D;&#x53EF;&#x80FD;&#x65E9;&#x7684;-filter-&#x64CD;&#x4F5C;">3. RDD &#x5C3D;&#x53EF;&#x80FD;&#x65E9;&#x7684; <code>filter</code> &#x64CD;&#x4F5C;</h3>
<p>&#x83B7;&#x53D6;&#x5230;&#x521D;&#x59CB;RDD&#x540E;&#xFF0C;&#x5E94;&#x8BE5;&#x8003;&#x8651;&#x5C3D;&#x65E9;&#x5730;&#x8FC7;&#x6EE4;&#x6389;&#x4E0D;&#x9700;&#x8981;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x8FDB;&#x800C;&#x51CF;&#x5C11;&#x5BF9;&#x5185;&#x5B58;&#x7684;&#x5360;&#x7528;&#xFF0C;&#x4ECE;&#x800C;&#x63D0;&#x5347;Spark&#x4F5C;&#x4E1A;&#x7684;&#x8FD0;&#x884C;&#x6548;&#x7387;&#x3002;</p>
<hr>
<h2 id="713-&#x5E76;&#x884C;&#x5EA6;&#x8C03;&#x8282;">7.1.3 &#x5E76;&#x884C;&#x5EA6;&#x8C03;&#x8282;</h2>
<p>Spark&#x4F5C;&#x4E1A;&#x4E2D;&#x7684;&#x5E76;&#x884C;&#x5EA6;&#x6307;&#x5404;&#x4E2A;stage &#x7684; task &#x7684;&#x6570;&#x91CF;&#x3002;</p>
<p>&#x5982;&#x679C;&#x5E76;&#x884C;&#x5EA6;&#x8BBE;&#x7F6E;&#x4E0D;&#x5408;&#x7406;&#x800C;&#x5BFC;&#x81F4;&#x5E76;&#x884C;&#x5EA6;&#x8FC7;&#x4F4E;&#xFF0C;&#x4F1A;&#x5BFC;&#x81F4;&#x8D44;&#x6E90;&#x7684;&#x6781;&#x5927;&#x6D6A;&#x8D39;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;20&#x4E2A; Executor&#xFF0C;&#x6BCF;&#x4E2A; Executor &#x5206;&#x914D; 3 &#x4E2A;CPU core&#xFF0C;&#x800C;Spark&#x4F5C;&#x4E1A;&#x6709; 40 &#x4E2A;task&#xFF0C;&#x8FD9;&#x6837;&#x6BCF;&#x4E2A;Executor&#x5206;&#x914D;&#x5230;&#x7684;task&#x4E2A;&#x6570;&#x662F;2&#x4E2A;&#xFF0C;&#x8FD9;&#x5C31;&#x4F7F;&#x5F97;&#x6BCF;&#x4E2A;Executor&#x6709;&#x4E00;&#x4E2A;CPU core&#x7A7A;&#x95F2;&#xFF0C;&#x5BFC;&#x81F4;&#x8D44;&#x6E90;&#x7684;&#x6D6A;&#x8D39;&#x3002;</p>
<p>&#x7406;&#x60F3;&#x7684;&#x5E76;&#x884C;&#x5EA6;&#x8BBE;&#x7F6E;&#xFF0C;&#x5E94;&#x8BE5;&#x662F;&#x8BA9;&#x5E76;&#x884C;&#x5EA6;&#x4E0E;&#x8D44;&#x6E90;&#x76F8;&#x5339;&#x914D;&#xFF0C;&#x7B80;&#x5355;&#x6765;&#x8BF4;&#x5C31;&#x662F;&#x5728;&#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#xFF0C;&#x5E76;&#x884C;&#x5EA6;&#x8981;&#x8BBE;&#x7F6E;&#x7684;&#x5C3D;&#x53EF;&#x80FD;&#x5927;&#xFF0C;&#x8FBE;&#x5230;&#x53EF;&#x4EE5;&#x5145;&#x5206;&#x5229;&#x7528;&#x96C6;&#x7FA4;&#x8D44;&#x6E90;&#x3002;&#x5408;&#x7406;&#x7684;&#x8BBE;&#x7F6E;&#x5E76;&#x884C;&#x5EA6;&#xFF0C;&#x53EF;&#x4EE5;&#x63D0;&#x5347;&#x6574;&#x4E2A; Spark &#x4F5C;&#x4E1A;&#x7684;&#x6027;&#x80FD;&#x548C;&#x8FD0;&#x884C;&#x901F;&#x5EA6;&#x3002;</p>
<p>Spark&#x5B98;&#x65B9;&#x63A8;&#x8350;&#xFF0C;task&#x6570;&#x91CF;&#x5E94;&#x8BE5;&#x8BBE;&#x7F6E;&#x4E3A;Spark&#x4F5C;&#x4E1A;&#x603B;CPU core&#x6570;&#x91CF;&#x7684;<code>2~3</code>&#x500D;&#x3002;&#x4E4B;&#x6240;&#x4EE5;&#x6CA1;&#x6709;&#x63A8;&#x8350;task&#x6570;&#x91CF;&#x4E0E;CPU core&#x603B;&#x6570;&#x76F8;&#x7B49;&#xFF0C;&#x662F;&#x56E0;&#x4E3A;task&#x7684;&#x6267;&#x884C;&#x65F6;&#x95F4;&#x4E0D;&#x540C;&#xFF0C;&#x6709;&#x7684;task&#x6267;&#x884C;&#x901F;&#x5EA6;&#x5FEB;&#x800C;&#x6709;&#x7684;task&#x6267;&#x884C;&#x901F;&#x5EA6;&#x6162;&#xFF0C;&#x5982;&#x679C;task&#x6570;&#x91CF;&#x4E0E;CPU core&#x603B;&#x6570;&#x76F8;&#x7B49;&#xFF0C;&#x90A3;&#x4E48;&#x6267;&#x884C;&#x5FEB;&#x7684;task&#x6267;&#x884C;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x4F1A;&#x51FA;&#x73B0;CPU core&#x7A7A;&#x95F2;&#x7684;&#x60C5;&#x51B5;&#x3002;&#x5982;&#x679C;task&#x6570;&#x91CF;&#x8BBE;&#x7F6E;&#x4E3A;CPU core&#x603B;&#x6570;&#x7684;<code>2~3</code>&#x500D;&#xFF0C;&#x90A3;&#x4E48;&#x4E00;&#x4E2A;task&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#x540E;&#xFF0C;CPU core&#x4F1A;&#x7ACB;&#x523B;&#x6267;&#x884C;&#x4E0B;&#x4E00;&#x4E2A;task&#xFF0C;&#x964D;&#x4F4E;&#x4E86;&#x8D44;&#x6E90;&#x7684;&#x6D6A;&#x8D39;&#xFF0C;&#x540C;&#x65F6;&#x63D0;&#x5347;&#x4E86;Spark&#x4F5C;&#x4E1A;&#x8FD0;&#x884C;&#x7684;&#x6548;&#x7387;&#x3002;</p>
<p>Spark&#x4F5C;&#x4E1A;&#x5E76;&#x884C;&#x5EA6;&#x7684;&#x8BBE;&#x7F6E;&#x5982;&#x4EE3;&#x7801;:</p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">val</span> conf <span class="token operator">=</span> <span class="token keyword">new</span> SparkConf<span class="token punctuation">(</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span>set<span class="token punctuation">(</span><span class="token string">&quot;spark.default.parallelism&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;500&quot;</span><span class="token punctuation">)</span>
</code></pre>
<hr>
<h2 id="714-&#x5E38;&#x89C4;&#x6027;&#x80FD;&#x8C03;&#x4F18;&#x56DB;&#xFF1A;&#x5E7F;&#x64AD;&#x5927;&#x53D8;&#x91CF;">7.1.4 &#x5E38;&#x89C4;&#x6027;&#x80FD;&#x8C03;&#x4F18;&#x56DB;&#xFF1A;&#x5E7F;&#x64AD;&#x5927;&#x53D8;&#x91CF;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;task &#x4E2D;&#x7684;&#x7B97;&#x5B50;&#x4E2D;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x4E86;&#x5916;&#x90E8;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x6BCF;&#x4E2A; task &#x90FD;&#x4F1A;&#x83B7;&#x53D6;&#x4E00;&#x4EFD;&#x53D8;&#x91CF;&#x7684;&#x590D;&#x672C;&#xFF0C;&#x8FD9;&#x5C31;&#x9020;&#x6210;&#x4E86;&#x5185;&#x5B58;&#x7684;&#x6781;&#x5927;&#x6D88;&#x8017;&#x3002;</p>
<ul>
<li>&#x4E00;&#x65B9;&#x9762;&#xFF0C;&#x5982;&#x679C;&#x540E;&#x7EED;&#x5BF9; RDD &#x8FDB;&#x884C;&#x6301;&#x4E45;&#x5316;&#xFF0C;&#x53EF;&#x80FD;&#x5C31;&#x65E0;&#x6CD5;&#x5C06; RDD &#x6570;&#x636E;&#x5B58;&#x5165;&#x5185;&#x5B58;&#xFF0C;&#x53EA;&#x80FD;&#x5199;&#x5165;&#x78C1;&#x76D8;&#xFF0C;&#x78C1;&#x76D8;IO&#x5C06;&#x4F1A;&#x4E25;&#x91CD;&#x6D88;&#x8017;&#x6027;&#x80FD;&#xFF1B;</li>
<li>&#x53E6;&#x4E00;&#x65B9;&#x9762;&#xFF0C;task&#x5728;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4E5F;&#x8BB8;&#x4F1A;&#x53D1;&#x73B0;&#x5806;&#x5185;&#x5B58;&#x65E0;&#x6CD5;&#x5B58;&#x653E;&#x65B0;&#x521B;&#x5EFA;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x5C31;&#x4F1A;&#x5BFC;&#x81F4;&#x9891;&#x7E41;&#x7684;GC&#xFF0C;GC&#x4F1A;&#x5BFC;&#x81F4;&#x5DE5;&#x4F5C;&#x7EBF;&#x7A0B;&#x505C;&#x6B62;&#xFF0C;&#x8FDB;&#x800C;&#x5BFC;&#x81F4;Spark&#x6682;&#x505C;&#x5DE5;&#x4F5C;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#xFF0C;&#x4E25;&#x91CD;&#x5F71;&#x54CD;Spark&#x6027;&#x80FD;&#x3002;</li>
</ul>
<p>&#x5047;&#x8BBE;&#x5F53;&#x524D;&#x4EFB;&#x52A1;&#x914D;&#x7F6E;&#x4E86;20&#x4E2A;Executor&#xFF0C;&#x6307;&#x5B9A;500&#x4E2A;task&#xFF0C;&#x6709;&#x4E00;&#x4E2A;20M&#x7684;&#x53D8;&#x91CF;&#x88AB;&#x6240;&#x6709;task&#x5171;&#x7528;&#xFF0C;&#x6B64;&#x65F6;&#x4F1A;&#x5728;500&#x4E2A;task&#x4E2D;&#x4EA7;&#x751F;500&#x4E2A;&#x526F;&#x672C;&#xFF0C;&#x8017;&#x8D39;&#x96C6;&#x7FA4;10G&#x7684;&#x5185;&#x5B58;&#xFF0C;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x4E86;&#x5E7F;&#x64AD;&#x53D8;&#x91CF;&#xFF0C; &#x90A3;&#x4E48;&#x6BCF;&#x4E2A;Executor&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#xFF0C;&#x4E00;&#x5171;&#x6D88;&#x8017;400M&#x5185;&#x5B58;&#xFF0C;&#x5185;&#x5B58;&#x6D88;&#x8017;&#x51CF;&#x5C11;&#x4E86;5&#x500D;&#x3002;</p>
<p>&#x5E7F;&#x64AD;&#x53D8;&#x91CF;&#x5728;&#x6BCF;&#x4E2A;Executor&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#xFF0C;&#x6B64;Executor&#x7684;&#x6240;&#x6709;task&#x5171;&#x7528;&#x6B64;&#x5E7F;&#x64AD;&#x53D8;&#x91CF;&#xFF0C;&#x8FD9;&#x8BA9;&#x53D8;&#x91CF;&#x4EA7;&#x751F;&#x7684;&#x526F;&#x672C;&#x6570;&#x91CF;&#x5927;&#x5927;&#x51CF;&#x5C11;&#x3002;</p>
<p>&#x5728;&#x521D;&#x59CB;&#x9636;&#x6BB5;&#xFF0C;&#x5E7F;&#x64AD;&#x53D8;&#x91CF;&#x53EA;&#x5728;Driver&#x4E2D;&#x6709;&#x4E00;&#x4EFD;&#x526F;&#x672C;&#x3002;task&#x5728;&#x8FD0;&#x884C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x60F3;&#x8981;&#x4F7F;&#x7528;&#x5E7F;&#x64AD;&#x53D8;&#x91CF;&#x4E2D;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x6B64;&#x65F6;&#x9996;&#x5148;&#x4F1A;&#x5728;&#x81EA;&#x5DF1;&#x672C;&#x5730;&#x7684;Executor&#x5BF9;&#x5E94;&#x7684;BlockManager&#x4E2D;&#x5C1D;&#x8BD5;&#x83B7;&#x53D6;&#x53D8;&#x91CF;&#xFF0C;&#x5982;&#x679C;&#x672C;&#x5730;&#x6CA1;&#x6709;&#xFF0C;BlockManager&#x5C31;&#x4F1A;&#x4ECE;Driver&#x6216;&#x8005;&#x5176;&#x4ED6;&#x8282;&#x70B9;&#x7684;BlockManager&#x4E0A;&#x8FDC;&#x7A0B;&#x62C9;&#x53D6;&#x53D8;&#x91CF;&#x7684;&#x590D;&#x672C;&#xFF0C;&#x5E76;&#x7531;&#x672C;&#x5730;&#x7684;BlockManager&#x8FDB;&#x884C;&#x7BA1;&#x7406;&#xFF1B;&#x4E4B;&#x540E;&#x6B64;Executor&#x7684;&#x6240;&#x6709;task&#x90FD;&#x4F1A;&#x76F4;&#x63A5;&#x4ECE;&#x672C;&#x5730;&#x7684;BlockManager&#x4E2D;&#x83B7;&#x53D6;&#x53D8;&#x91CF;&#x3002;</p>
<hr>
<h2 id="715-kryo-&#x5E8F;&#x5217;&#x5316;">7.1.5 Kryo &#x5E8F;&#x5217;&#x5316;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;Spark &#x4F7F;&#x7528; Java &#x7684;&#x5E8F;&#x5217;&#x5316;&#x673A;&#x5236;&#x3002;Java&#x7684;&#x5E8F;&#x5217;&#x5316;&#x673A;&#x5236;&#x4F7F;&#x7528;&#x65B9;&#x4FBF;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x989D;&#x5916;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x5728;&#x7B97;&#x5B50;&#x4E2D;&#x4F7F;&#x7528;&#x7684;&#x53D8;&#x91CF;&#x5B9E;&#x73B0;<code>Serializable</code>&#x63A5;&#x53E3;&#x5373;&#x53EF;&#xFF0C;&#x4F46;&#x662F;&#xFF0C;Java &#x5E8F;&#x5217;&#x5316;&#x673A;&#x5236;&#x7684;&#x6548;&#x7387;&#x4E0D;&#x9AD8;&#xFF0C;&#x5E8F;&#x5217;&#x5316;&#x901F;&#x5EA6;&#x6162;&#x5E76;&#x4E14;&#x5E8F;&#x5217;&#x5316;&#x540E;&#x7684;&#x6570;&#x636E;&#x6240;&#x5360;&#x7528;&#x7684;&#x7A7A;&#x95F4;&#x4F9D;&#x7136;&#x8F83;&#x5927;&#x3002;</p>
<p>Kryo&#x5E8F;&#x5217;&#x5316;&#x673A;&#x5236;&#x6BD4;Java&#x5E8F;&#x5217;&#x5316;&#x673A;&#x5236;&#x6027;&#x80FD;&#x63D0;&#x9AD8;10&#x500D;&#x5DE6;&#x53F3;&#xFF0C;Spark&#x4E4B;&#x6240;&#x4EE5;&#x6CA1;&#x6709;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;Kryo&#x4F5C;&#x4E3A;&#x5E8F;&#x5217;&#x5316;&#x7C7B;&#x5E93;&#xFF0C;&#x662F;&#x56E0;&#x4E3A;&#x5B83;&#x4E0D;&#x652F;&#x6301;&#x6240;&#x6709;&#x5BF9;&#x8C61;&#x7684;&#x5E8F;&#x5217;&#x5316;&#xFF0C;&#x540C;&#x65F6;Kryo&#x9700;&#x8981;&#x7528;&#x6237;&#x5728;&#x4F7F;&#x7528;&#x524D;&#x6CE8;&#x518C;&#x9700;&#x8981;&#x5E8F;&#x5217;&#x5316;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x4E0D;&#x591F;&#x65B9;&#x4FBF;&#xFF0C;&#x4F46;&#x4ECE;Spark 2.0.0&#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;&#x7B80;&#x5355;&#x7C7B;&#x578B;&#x3001;&#x7B80;&#x5355;&#x7C7B;&#x578B;&#x6570;&#x7EC4;&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;&#x7684;Shuffling RDDs &#x5DF2;&#x7ECF;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;Kryo&#x5E8F;&#x5217;&#x5316;&#x65B9;&#x5F0F;&#x4E86;&#x3002;</p>
<pre class="language-"><code class="lang-java"><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyKryoRegistrator</span> <span class="token keyword">implements</span> <span class="token class-name">KryoRegistrator</span><span class="token punctuation">{</span>
  <span class="token annotation punctuation">@Override</span>
  <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">registerClasses</span><span class="token punctuation">(</span>Kryo kryo<span class="token punctuation">)</span><span class="token punctuation">{</span>
    kryo<span class="token punctuation">.</span><span class="token function">register</span><span class="token punctuation">(</span>StartupReportLogs<span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-scala"><span class="token comment">//&#x521B;&#x5EFA;SparkConf&#x5BF9;&#x8C61;</span>
<span class="token keyword">val</span> conf <span class="token operator">=</span> <span class="token keyword">new</span> SparkConf<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>setMaster<span class="token punctuation">(</span>&#x2026;<span class="token punctuation">)</span><span class="token punctuation">.</span>setAppName<span class="token punctuation">(</span>&#x2026;<span class="token punctuation">)</span>
<span class="token comment">//&#x4F7F;&#x7528;Kryo&#x5E8F;&#x5217;&#x5316;&#x5E93;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x4F7F;&#x7528;Java&#x5E8F;&#x5217;&#x5316;&#x5E93;&#xFF0C;&#x9700;&#x8981;&#x628A;&#x8BE5;&#x884C;&#x5C4F;&#x853D;&#x6389;</span>
conf<span class="token punctuation">.</span>set<span class="token punctuation">(</span><span class="token string">&quot;spark.serializer&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;org.apache.spark.serializer.KryoSerializer&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token comment">//&#x5728;Kryo&#x5E8F;&#x5217;&#x5316;&#x5E93;&#x4E2D;&#x6CE8;&#x518C;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x96C6;&#x5408;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x4F7F;&#x7528;Java&#x5E8F;&#x5217;&#x5316;&#x5E93;&#xFF0C;&#x9700;&#x8981;&#x628A;&#x8BE5;&#x884C;&#x5C4F;&#x853D;&#x6389;</span>
conf<span class="token punctuation">.</span>set<span class="token punctuation">(</span><span class="token string">&quot;spark.kryo.registrator&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;atguigu.com.MyKryoRegistrator&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<hr>
<h2 id="716-&#x8C03;&#x8282;&#x672C;&#x5730;&#x5316;&#x7B49;&#x5F85;&#x65F6;&#x95F4;">7.1.6 &#x8C03;&#x8282;&#x672C;&#x5730;&#x5316;&#x7B49;&#x5F85;&#x65F6;&#x95F4;</h2>
<p>Spark &#x4F5C;&#x4E1A;&#x8FD0;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;Driver &#x4F1A;&#x5BF9;&#x6BCF;&#x4E00;&#x4E2A; stage &#x7684; task &#x8FDB;&#x884C;&#x5206;&#x914D;&#x3002;&#x6839;&#x636E; Spark &#x7684; task &#x5206;&#x914D;&#x7B97;&#x6CD5;&#xFF0C;Spark&#x5E0C;&#x671B;task&#x80FD;&#x591F;&#x8FD0;&#x884C;&#x5728;&#x5B83;&#x8981;&#x8BA1;&#x7B97;&#x7684;&#x6570;&#x636E;&#x6240;&#x5728;&#x7684;&#x8282;&#x70B9;&#xFF08;&#x6570;&#x636E;&#x672C;&#x5730;&#x5316;&#x601D;&#x60F3;&#xFF09;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x6570;&#x636E;&#x7684;&#x7F51;&#x7EDC;&#x4F20;&#x8F93;&#x3002;</p>
<p>&#x901A;&#x5E38;&#x6765;&#x8BF4;&#xFF0C;task&#x53EF;&#x80FD;&#x4E0D;&#x4F1A;&#x88AB;&#x5206;&#x914D;&#x5230;&#x5B83;&#x5904;&#x7406;&#x7684;&#x6570;&#x636E;&#x6240;&#x5728;&#x7684;&#x8282;&#x70B9;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4E9B;&#x8282;&#x70B9;&#x53EF;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x53EF;&#x80FD;&#x5DF2;&#x7ECF;&#x7528;&#x5C3D;&#xFF0C;&#x6B64;&#x65F6;&#xFF0C;Spark&#x4F1A;&#x7B49;&#x5F85;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#xFF0C;&#x9ED8;&#x8BA4;<code>3s</code>&#xFF0C;&#x5982;&#x679C;&#x7B49;&#x5F85;&#x6307;&#x5B9A;&#x65F6;&#x95F4;&#x540E;&#x4ECD;&#x7136;&#x65E0;&#x6CD5;&#x5728;&#x6307;&#x5B9A;&#x8282;&#x70B9;&#x8FD0;&#x884C;&#xFF0C;&#x90A3;&#x4E48;&#x4F1A;&#x81EA;&#x52A8;&#x964D;&#x7EA7;&#xFF0C;&#x5C1D;&#x8BD5;&#x5C06;task&#x5206;&#x914D;&#x5230;&#x6BD4;&#x8F83;&#x5DEE;&#x7684;&#x672C;&#x5730;&#x5316;&#x7EA7;&#x522B;&#x6240;&#x5BF9;&#x5E94;&#x7684;&#x8282;&#x70B9;&#x4E0A;&#xFF0C;&#x6BD4;&#x5982;&#x5C06;task&#x5206;&#x914D;&#x5230;&#x79BB;&#x5B83;&#x8981;&#x8BA1;&#x7B97;&#x7684;&#x6570;&#x636E;&#x6BD4;&#x8F83;&#x8FD1;&#x7684;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x884C;&#x8BA1;&#x7B97;&#xFF0C;&#x5982;&#x679C;&#x5F53;&#x524D;&#x7EA7;&#x522B;&#x4ECD;&#x7136;&#x4E0D;&#x884C;&#xFF0C;&#x90A3;&#x4E48;&#x7EE7;&#x7EED;&#x964D;&#x7EA7;&#x3002;</p>
<p>&#x5F53;task&#x8981;&#x5904;&#x7406;&#x7684;&#x6570;&#x636E;&#x4E0D;&#x5728;task&#x6240;&#x5728;&#x8282;&#x70B9;&#x4E0A;&#x65F6;&#xFF0C;&#x4F1A;&#x53D1;&#x751F;&#x6570;&#x636E;&#x7684;&#x4F20;&#x8F93;&#x3002;task&#x4F1A;&#x901A;&#x8FC7;&#x6240;&#x5728;&#x8282;&#x70B9;&#x7684;BlockManager&#x83B7;&#x53D6;&#x6570;&#x636E;&#xFF0C;BlockManager&#x53D1;&#x73B0;&#x6570;&#x636E;&#x4E0D;&#x5728;&#x672C;&#x5730;&#x65F6;&#xFF0C;&#x4F1A;&#x901A;&#x8FC7;&#x7F51;&#x7EDC;&#x4F20;&#x8F93;&#x7EC4;&#x4EF6;&#x4ECE;&#x6570;&#x636E;&#x6240;&#x5728;&#x8282;&#x70B9;&#x7684;BlockManager&#x5904;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x3002;</p>
<p>&#x7F51;&#x7EDC;&#x4F20;&#x8F93;&#x6570;&#x636E;&#x7684;&#x60C5;&#x51B5;&#x662F;&#x6211;&#x4EEC;&#x4E0D;&#x613F;&#x610F;&#x770B;&#x5230;&#x7684;&#xFF0C;&#x5927;&#x91CF;&#x7684;&#x7F51;&#x7EDC;&#x4F20;&#x8F93;&#x4F1A;&#x4E25;&#x91CD;&#x5F71;&#x54CD;&#x6027;&#x80FD;&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x901A;&#x8FC7;&#x8C03;&#x8282;&#x672C;&#x5730;&#x5316;&#x7B49;&#x5F85;&#x65F6;&#x957F;&#xFF0C;&#x5982;&#x679C;&#x5728;&#x7B49;&#x5F85;&#x65F6;&#x957F;&#x8FD9;&#x6BB5;&#x65F6;&#x95F4;&#x5185;&#xFF0C;&#x76EE;&#x6807;&#x8282;&#x70B9;&#x5904;&#x7406;&#x5B8C;&#x6210;&#x4E86;&#x4E00;&#x90E8;&#x5206;task&#xFF0C;&#x90A3;&#x4E48;&#x5F53;&#x524D;&#x7684;task&#x5C06;&#x6709;&#x673A;&#x4F1A;&#x5F97;&#x5230;&#x6267;&#x884C;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x80FD;&#x591F;&#x6539;&#x5584;Spark&#x4F5C;&#x4E1A;&#x7684;&#x6574;&#x4F53;&#x6027;&#x80FD;&#x3002;</p>
<p>&#x8868;2-3 Spark&#x672C;&#x5730;&#x5316;&#x7B49;&#x7EA7;</p>
<table>
<thead>
<tr>
<th><strong>&#x540D;&#x79F0;</strong></th>
<th><strong>&#x89E3;&#x6790;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>PROCESS_LOCAL</strong></td>
<td>&#x8FDB;&#x7A0B;&#x672C;&#x5730;&#x5316;&#xFF0C;task&#x548C;&#x6570;&#x636E;&#x5728;&#x540C;&#x4E00;&#x4E2A;Executor&#x4E2D;&#xFF0C;&#x6027;&#x80FD;&#x6700;&#x597D;&#x3002;</td>
</tr>
<tr>
<td><strong>NODE_LOCAL</strong></td>
<td>&#x8282;&#x70B9;&#x672C;&#x5730;&#x5316;&#xFF0C;task&#x548C;&#x6570;&#x636E;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x4E2D;&#xFF0C;&#x4F46;&#x662F;task&#x548C;&#x6570;&#x636E;&#x4E0D;&#x5728;&#x540C;&#x4E00;&#x4E2A;Executor&#x4E2D;&#xFF0C;&#x6570;&#x636E;&#x9700;&#x8981;&#x5728;&#x8FDB;&#x7A0B;&#x95F4;&#x8FDB;&#x884C;&#x4F20;&#x8F93;&#x3002;</td>
</tr>
<tr>
<td><strong>RACK_LOCAL</strong></td>
<td>&#x673A;&#x67B6;&#x672C;&#x5730;&#x5316;&#xFF0C;task&#x548C;&#x6570;&#x636E;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x673A;&#x67B6;&#x7684;&#x4E24;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#xFF0C;&#x6570;&#x636E;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x7F51;&#x7EDC;&#x5728;&#x8282;&#x70B9;&#x4E4B;&#x95F4;&#x8FDB;&#x884C;&#x4F20;&#x8F93;&#x3002;</td>
</tr>
<tr>
<td><strong>NO_PREF</strong></td>
<td>&#x5BF9;&#x4E8E;task&#x6765;&#x8BF4;&#xFF0C;&#x4ECE;&#x54EA;&#x91CC;&#x83B7;&#x53D6;&#x90FD;&#x4E00;&#x6837;&#xFF0C;&#x6CA1;&#x6709;&#x597D;&#x574F;&#x4E4B;&#x5206;&#x3002;</td>
</tr>
<tr>
<td><strong>ANY</strong></td>
<td>task&#x548C;&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x5728;&#x96C6;&#x7FA4;&#x7684;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#xFF0C;&#x800C;&#x4E14;&#x4E0D;&#x5728;&#x4E00;&#x4E2A;&#x673A;&#x67B6;&#x4E2D;&#xFF0C;&#x6027;&#x80FD;&#x6700;&#x5DEE;&#x3002;</td>
</tr>
</tbody>
</table>
<p>&#x5728;Spark&#x9879;&#x76EE;&#x5F00;&#x53D1;&#x9636;&#x6BB5;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>client</code>&#x6A21;&#x5F0F;&#x5BF9;&#x7A0B;&#x5E8F;&#x8FDB;&#x884C;&#x6D4B;&#x8BD5;&#xFF0C;&#x6B64;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x672C;&#x5730;&#x770B;&#x5230;&#x6BD4;&#x8F83;&#x5168;&#x7684;&#x65E5;&#x5FD7;&#x4FE1;&#x606F;&#xFF0C;&#x65E5;&#x5FD7;&#x4FE1;&#x606F;&#x4E2D;&#x6709;&#x660E;&#x786E;&#x7684;<code>task</code>&#x6570;&#x636E;&#x672C;&#x5730;&#x5316;&#x7684;&#x7EA7;&#x522B;&#xFF0C;&#x5982;&#x679C;&#x5927;&#x90E8;&#x5206;&#x90FD;&#x662F;<code>PROCESS_LOCAL</code>&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x65E0;&#x9700;&#x8FDB;&#x884C;&#x8C03;&#x8282;&#xFF0C;&#x4F46;&#x662F;&#x5982;&#x679C;&#x53D1;&#x73B0;&#x5F88;&#x591A;&#x7684;&#x7EA7;&#x522B;&#x90FD;&#x662F;<code>NODE_LOCAL&#x3001;ANY</code>&#xFF0C;&#x90A3;&#x4E48;&#x9700;&#x8981;&#x5BF9;&#x672C;&#x5730;&#x5316;&#x7684;&#x7B49;&#x5F85;&#x65F6;&#x957F;&#x8FDB;&#x884C;&#x8C03;&#x8282;&#xFF0C;&#x901A;&#x8FC7;&#x5EF6;&#x957F;&#x672C;&#x5730;&#x5316;&#x7B49;&#x5F85;&#x65F6;&#x957F;&#xFF0C;&#x770B;&#x770B;<code>task</code>&#x7684;&#x672C;&#x5730;&#x5316;&#x7EA7;&#x522B;&#x6709;&#x6CA1;&#x6709;&#x63D0;&#x5347;&#xFF0C;&#x5E76;&#x89C2;&#x5BDF;Spark&#x4F5C;&#x4E1A;&#x7684;&#x8FD0;&#x884C;&#x65F6;&#x95F4;&#x6709;&#x6CA1;&#x6709;&#x7F29;&#x77ED;&#x3002;
&#x6CE8;&#x610F;&#xFF0C;&#x8FC7;&#x72B9;&#x4E0D;&#x53CA;&#xFF0C;&#x4E0D;&#x8981;&#x5C06;&#x672C;&#x5730;&#x5316;&#x7B49;&#x5F85;&#x65F6;&#x957F;&#x5EF6;&#x957F;&#x5730;&#x8FC7;&#x957F;&#xFF0C;&#x5BFC;&#x81F4;&#x56E0;&#x4E3A;&#x5927;&#x91CF;&#x7684;&#x7B49;&#x5F85;&#x65F6;&#x957F;&#xFF0C;&#x4F7F;&#x5F97;Spark&#x4F5C;&#x4E1A;&#x7684;&#x8FD0;&#x884C;&#x65F6;&#x95F4;&#x53CD;&#x800C;&#x589E;&#x52A0;&#x4E86;&#x3002;</p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">val</span> conf <span class="token operator">=</span> <span class="token keyword">new</span> SparkConf<span class="token punctuation">(</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span>set<span class="token punctuation">(</span><span class="token string">&quot;spark.locality.wait&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;6&quot;</span><span class="token punctuation">)</span>
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x5C1A;&#x7845;&#x8C37;&#x5927;&#x6570;&#x636E; 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification"><br>&#x8BE5;&#x6587;&#x4EF6;&#x6700;&#x540E;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-06-10 22:02:49
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../di-7-zhang-spark-xing-neng-you-hua.html" class="navigation navigation-prev " aria-label="Previous page: 第 7 章 Spark 性能优化">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="72-suan-zi-diao-you.html" class="navigation navigation-next " aria-label="Next page: 7.2 算子调优">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"7.1 常规性能调优","level":"2.1.1","depth":2,"next":{"title":"7.2 算子调优","level":"2.1.2","depth":2,"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/72-suan-zi-diao-you.md","ref":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/72-suan-zi-diao-you.md","articles":[]},"previous":{"title":"第 7 章 Spark 性能优化","level":"2.1","depth":1,"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua.md","ref":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua.md","articles":[{"title":"7.1 常规性能调优","level":"2.1.1","depth":2,"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/71-chang-gui-xing-neng-diao-you.md","ref":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/71-chang-gui-xing-neng-diao-you.md","articles":[]},{"title":"7.2 算子调优","level":"2.1.2","depth":2,"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/72-suan-zi-diao-you.md","ref":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/72-suan-zi-diao-you.md","articles":[]},{"title":"7.3 Shuffle 调优","level":"2.1.3","depth":2,"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/73-shuffle-diao-you.md","ref":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/73-shuffle-diao-you.md","articles":[]},{"title":"7.4 JVM 调优","level":"2.1.4","depth":2,"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/74-jvm-diao-you.md","ref":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/74-jvm-diao-you.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["splitter","expandable-chapters-small","page-toc-button","-highlight","prism","prism-themes","tbfed-pagefooter","sitemap","change_girls","livereload"],"styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 尚硅谷大数据 2019","modify_label":"<br>该文件最后修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"]},"disqus":{"shortName":"zhenchao125"},"livereload":{},"splitter":{},"change_girls":{"time":30,"urls":["http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/62171757.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/83394736.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/15906185.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/15906185.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/3394270.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/65028582.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/20359261.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/37472401.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/3355397.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/11075549.jpg-atguiguImg"]},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"sitemap":{"hostname":"http://bigdataatguigu.applinzi.com/"},"page-toc-button":{"maxTocDepth":3,"minTocSize":2},"prism-themes":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":" 李振超","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"大数据 bigdata_spark_kernel-optimize_atguigu 课堂笔记","language":"zh-hans","links":{"sidebar":{"联系我们":"http://www.atguigu.com/"}},"gitbook":"*","description":"课堂笔记,学生提前预习"},"file":{"path":"di-2-bu-52063a-spark-xing-neng-you-hua-he-gu-zhang-chu-li/di-7-zhang-spark-xing-neng-you-hua/71-chang-gui-xing-neng-diao-you.md","mtime":"2019-06-10T14:02:49.833Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-15T00:07:35.887Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-change_girls/girls.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

